#!/usr/bin/python
# -*- coding: gb2312 -*-

import SocketServer, time
import os, time, sys, thread

myHost = ""
myPort = 51769

def now():
    return time.ctime(time.time())

class myhand(SocketServer.BaseRequestHandler):
    """
    properties: request, client_address, server
                (sockobj)                (ThreadingTCPServer)
    """
    
    def handle(self):
        print self.client_address, now(), self.request, self.server
        time.sleep(5)
        while 1:
            data = self.request.recv(1024)
            if not data: break
            self.request.send('=>%s at %s'%(data, now()))
        self.request.close()

sev = SocketServer.ThreadingTCPServer((myHost,myPort), myhand)
sev.serve_forever()
